<%@ Page Language="C#" MasterPageFile="~/MasterPages/Learning.Master" AutoEventWireup="true" CodeBehind="RSS.aspx.cs" Inherits="Mindscape.BackgroundMotion.Website.Learn.RSS" Title="Code: Learn about RSS" %>
<asp:Content ID="Content3" ContentPlaceHolderID="BodyContent" runat="server">

    <h2>What is RSS?</h2>
    
    <p>
    <i>RSS is a family of web feed formats used to publish frequently updated digital content, such as blogs, news feeds or podcasts.<br />
    <br />
    Users of RSS content use software programs called "feed readers" or "feed aggregators". The user subscribes to a feed by entering a link of the feed into the reader program. The reader can then check the user's subscribed feeds to see if any of those feeds have new content since the last time it was checked, and, if so, retrieve that content and present it to the user.</i><br />
    <a href="http://en.wikipedia.org/wiki/RSS_(file_format)">Wikipedia article on RSS</a><br />
    <br />
    RSS has become the de-facto standard for syndication of content over the Internet. Feeds from blogs, news sites or even standard business systems is now common
    and the orange "feed icon" <img src="/Images/Dev/RssFeed.png" width="16px" /> is widely recognises as a link to syndicated content.
    <br />
    <br />
    In <b>BackgroundMotion</b> we allow any view of the contribution data to be subscribed to through RSS.
    
    We used the ASP.NET RSS Toolkit created by <a href="http://blogs.msdn.com/dmitryr/">Dmitry Robsman</a> which allowed us to add
    support for RSS in about 10 minutes!
    </p>
    
    <h2>Integrating RSS into your applications</h2>
    
    <p>
    Syndication of content through RSS is done by creating an XML feed which complies with the RSS 0.91 or 2.0 formats. Typically
    most people today use RSS 2.0. Rather than having to understand the format yourself, you can use the same open source library
    that we have used on BackgroundMotion and leverage it to create the XML you will need to publish your content.<br />
    <br />
    To get started, download the latest version of the <a href="http://www.codeplex.com/ASPNETRSSToolkit">ASP.NET RSS Toolkit project from CodePlex</a>.
    <br />
    <h3>Step 1</h3>
    You will need to include a reference to RSSToolkit.dll in your solution. The classes we are going to be working with are <span style="font-family: Consolas, Verdana; font-size: 11pt; color: navy; font-weight: bold;">GenericRssChannel</span>, 
    and <span style="font-family: Consolas, Verdana; font-size: 11pt; color: navy; font-weight: bold;">GenericRssElement</span>.
    <br />
    <br />
    <h3>Step 2</h3>
    An RSS feed contains a number of syndicated content items and is wrapped up in a channel element which is a container which describes the metadata 
    about the feed which you are viewing. To represent this using the toolkit we create a new GenericRssChannel and assign some specific values to it, for example:
    </p>

    <br />
    <br />
    <div style="font-family: Consolas, Verdana; font-size: 11pt; color: black; background: white;">
    <p style="margin: 0px;"><span style="color: navy; font-weight: bold;">GenericRssChannel</span> rssFeed = <span style="color: blue;">new</span> <span style="color: navy; font-weight: bold;">GenericRssChannel</span>();</p>
    <p style="margin: 0px;">rssFeed[<span style="color: maroon;">"title"</span>] = channel;</p>
    <p style="margin: 0px;">rssFeed[<span style="color: maroon;">"link"</span>] = <span style="color: maroon;">"http://www.backgroundmotion.com"</span>;</p>
    <p style="margin: 0px;">rssFeed[<span style="color: maroon;">"description"</span>] = description;</p>
    <p style="margin: 0px;">rssFeed[<span style="color: maroon;">"copyright"</span>] = <span style="color: maroon;">"(c) 2007 - Mindscape"</span>;</p>
    <p style="margin: 0px;">rssFeed[<span style="color: maroon;">"lastBuildDate"</span>] = <span style="color: navy; font-weight: bold;">DateTime</span>.Now.ToString(<span style="color: maroon;">"ddd, dd MMM yyyy HH:mm:ss"</span>);</p>
    <p style="margin: 0px;">rssFeed[<span style="color: maroon;">"generator"</span>] = <span style="color: maroon;">"Background Motion RSS"</span>;</p>
    <p style="margin: 0px;">rssFeed[<span style="color: maroon;">"managingEditor"</span>] = <span style="color: maroon;">"webmaster@backgroundmotion.com"</span>;</p>
    <p style="margin: 0px;">rssFeed[<span style="color: maroon;">"webMaster"</span>] = <span style="color: maroon;">"webmaster@backgroundmotion.com"</span>;</p>
    </div>

    <p>
    <h3>Step 3</h3>
    For each item in our collection of content, we create a GenericRssElement and assign the appropriate content values. The item is then added to the feed.
    </p>
    
    <br />
    <br />
    <div style="font-family: Consolas, Verdana; font-size: 11pt; color: black; background: white;">
    <p style="margin: 0px;"><span style="color: navy; font-weight: bold;">GenericRssElement</span> item = <span style="color: blue;">new</span> <span style="color: navy; font-weight: bold;">GenericRssElement</span>();</p>
    <p style="margin: 0px;">item[<span style="color: maroon;">"title"</span>] = contribution.Title;</p>
    <p style="margin: 0px;">item[<span style="color: maroon;">"description"</span>] = contribution.Description;</p>
    <p style="margin: 0px;">item[<span style="color: maroon;">"pubDate"</span>] = contribution.AddedOn.ToString(<span style="color: maroon;">"ddd, dd MMM yyyy HH:mm:ss"</span>);</p>
    <p style="margin: 0px;">item[<span style="color: maroon;">"category"</span>] = contribution.ContentType.Description;</p>
    <p style="margin: 0px;">item[<span style="color: maroon;">"guid"</span>] = contribution.Id.ToString();</p>
    </div>
  
    <p>
    <h3>Step 4</h3>
    To return an XML document, we can call the SaveAsXml method on the GenericRssChannel class. This can then be written to the output
    stream of a web request to provide a consumable feed.
    </p>
    
    <br />

    <p>
    <b>Tip:</b> In a future release of the .NET Framework there will be a new framework library called System.Syndication which will 
    provide standard platform support with .NET for syndication of content through any of the standard syndication formats.
    </p>
        
</asp:Content>
